import * as types from './../constants/ActionTypes';

/*
 * 微信补全资料 step 1
 ================================================================*/
export function wxupgrade({phone, captcha} = {}) {
    return (dispatch) => {
        let payload = {
            wxupgrade_status: 1,
            message: '加载中',
            phone : phone,
            captcha : captcha
        };
        
        dispatch({
            payload,
            type : types.WXUPGRADE
        });
    };
}

/*
 * 微信补全资料 step 2
 ================================================================*/
export function wxupgrade2({phone, captcha, password, deviceid, baidu_devicetype, baiduid} = {}){
    return (dispatch) => {
        
        let payload = {
            wxupgrade2_status: 0,
            message: '加载中',
            phone : phone,
            captcha : captcha
        };

        dispatch({
            payload, 
            type : [types.WXUPGRADE, types.WXUPGRADE_SUCCESS, types.WXUPGRADE_FAILURE],
            meta: {
                fetch: [`members/reg`, {
                        method: 'post',
                        body: `phone=${phone}&captcha=${captcha}&password=${password}&deviceid=${deviceid}&baidu_devicetype=${baidu_devicetype}&baiduid=${baiduid}`
                    }
                ]
            }  
        });
    };
}
